package com.example.appxi;

import android.app.Activity;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.widget.Toast;

public class IntroActivity extends Activity{
	Handler h;
	ConnectivityManager cManager; 
	NetworkInfo mobile; 
	NetworkInfo wifi; 
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		setContentView(R.layout.activity_intro);
		h = new Handler();
		
	   	cManager=(ConnectivityManager)getSystemService(this.CONNECTIVITY_SERVICE); 
	   	mobile = cManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); 
	   	wifi = cManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); 
		
	   	if(mobile.isConnected() || wifi.isConnected())
	   	{
	   		h.postDelayed(irun, 1500);
	   		
	
	   	}
	   	else
	   	{ 
	   		
	   		Toast toast = Toast.makeText(this, "네트워크 연결상태를 확인해주세요", Toast.LENGTH_LONG);	
	   		toast.show();
	   		
		}
		
	   	 

	   	
	}

	
	Runnable irun = new Runnable() {
		public void run(){

			Intent i = new Intent(IntroActivity.this,MainActivity.class);
			startActivity(i);
			finish();
			
			overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
		}
		};
		

	
	public void onBackPressed() {
		super.onBackPressed();
		h.removeCallbacks(irun);
	}
}